<!--********************************************************************
* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title data-i18n="resources.title_animatorPoint"></title>
    <style type="text/css">
        body {
            margin: 0;
            overflow: hidden;
            background: #fff;
            width: 100%;
            height: 100%
        }

        #map {
            position: absolute;
            width: 100%;
            height: 100%;
        }

        #toolbar {
            position: absolute;
            top: 50px;
            right: 10px;
            text-align: center;
            z-index: 100;
            border-radius: 4px;
        }
    </style>
</head>
<body>
<div id="toolbar" class="panel panel-primary">
    <div class='panel-heading'>
        <h5 class='panel-title text-center' data-i18n="resources.title_animatorPoint"></h5></div>
    <div class='panel-body content'>
        <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_start" onclick="startAnimator()"/>&nbsp;
        <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_pause" onclick="pauseAnimator()"/>&nbsp;
        <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_removeOldPoint" data-i18n="[title]resources.text_removeDrawedPoint" onclick="removeDrawedFeature()"/>
    </div>
</div>
<div id="map"></div>
<script type="text/javascript" include="bootstrap,widgets.alert" src="../js/include-web.js"></script>
<script type="text/javascript" exclude="iclient-classic" src="../../dist/classic/include-classic.js"></script>
<script>
    var map, layer, animatorVector;
    var style =
        {
            fillColor: "#339933",
            fillOpacity: 1,
            strokeOpacity: 0,
            pointRadius: 5
        };
    init();

    function init() {
        if (!document.createElement('canvas').getContext) {
            widgets.alert.showAlert(resources.msg_supportCanvas, false);
            return;
        }
        map = new SuperMap.Map("map", {
            controls: [
                new SuperMap.Control.ScaleLine(),
                new SuperMap.Control.Zoom(),
                new SuperMap.Control.MousePosition(),
                new SuperMap.Control.Navigation({
                    dragPanOptions: {
                        enableKinetic: true
                    }
                })]
        });
        map.addControl(new SuperMap.Control.LayerSwitcher(), new SuperMap.Pixel(42, 80));

        layer = new SuperMap.Layer.OSM("OSM");

        map.addLayers([layer]);

        map.setCenter(new SuperMap.LonLat(0, 0), 1);

        animatorVector = new SuperMap.Layer.AnimatorVector("Vector Layer", {needRecordDrawedFeature: true}, {
            speed: 0.05,
            startTime: 0,
            endTime: 100
        });
        map.addLayers([animatorVector]);
        addPoint();
    }

    function addPoint() {
        var pointFeatures = [];
        var features = [];
        var ti = 100;
        var num = 100;

        for (var i = 0; i < ti; i++) {
            for (var j = 0; j < num; j++) {
                if (features.length >= num) {
                    var x = features[features.length - num].geometry.x;
                    var y = features[features.length - num].geometry.y;
                }
                else {
                    var x = Math.random() * 20037508 * 2 - 20037508;
                    var y = Math.random() * 20037508 * 2 - 20037508;
                }

                var xd = Math.random() * 1375080 * 2 - 1375080;
                var yd = Math.random() * 1375080 * 2 - 1375080;
                var point = new SuperMap.Geometry.Point(x + xd, y + yd);
                var pointFeature = new SuperMap.Feature.Vector(point, {
                    FEATUREID: j,
                    TIME: 0 + i * 1
                }, style);
                features.push(pointFeature);
            }
        }
        animatorVector.addFeatures(features);
    }

    function startAnimator() {
        animatorVector.animator.start();
    }

    function pauseAnimator() {
        animatorVector.animator.pause();
    }

    function removeDrawedFeature() {
        var features = animatorVector.getDrawedFeatures();
        animatorVector.removeFeatures(features);
    }

</script>

</body>
</html>